class Practice {
  constructor() {

  }
  static findIps(str = '') {
    return str.match(Practice.IpReg);
  }

  static get IpReg() {
    return /\d{1,3}(\.\d{1,3}){3}/gm
  }

  static findSimpleFunctions(str = '') {
    return str.match(Practice.FuncReg);
  }

  static get FuncReg() {
    return /function\s+[a-zA-Z_$]+[\w$_]*\s*\(\s*\)\s*\{\s*\}/gm
  }

  static shuffleArray(arr1 = [], arr2 = []) {
    if (!arr1 || arr1.constructor !== Array || !arr2 || arr2.constructor !== Array) {
      throw new Error('请传入2个数组');
    }
    let min = arr1.length > arr2.length ? arr2 : arr1,
      max = arr1.length > arr2.length ? arr1 : arr2,
      result = [];
    for (let i = 0; i < min.length; i++) {
      result.push(min[i]);
      result.push(max[i]);
    }
    if(min.length != max.length){
      Array.prototype.push.apply(result, max.slice(min.length));
    }


    return result;
  }

  static shaizi(n = 1) {
    return Math.ceil(6 * n * Math.random());
  }

  static sleep(time){
    return new Promise((resolve, reject) => {
      setTimeout(() => resolve(time), time);
    });
  }

  static async test() {
    await Practice.sleep(2000); //
    console.log(2000);
    await Practice.sleep(1000); //
    console.log(1000);
  }

}

const str = `fjskfjsl fjkdsjfkls fjklsfjlsd127.0.0.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf
asfjs fed jfjf jf sdjfsi jfi jafis function dd ( ) { }afjsdiajf iosa function abc(){} jfisjad fjsaiofjaoissf
addedfds`;
console.log(Practice.findIps(str));
console.log(Practice.findSimpleFunctions(str));

const arr1 = [1, 2, 3],
  arr2 = [4, 5, 6, 7, 8, 9];
console.log(Practice.shuffleArray(arr1, arr2));
for (let i = 0; i < 10; i++) {
  console.log(Practice.shaizi(2));
}
Practice.test();
